<script type="text/javascript">
<!--
function alter_published_state(state, id, ele){
	if(ele.className == "Published") var index = $(".Published").index(ele);
	else if(ele.className == "UnPublished") var index = $(".UnPublished").index(ele);
	$.post("<?php echo ADMIN_COMPONENT_PATH.COMPONENT_PATH."functions/change_published.php";?>", { published: state, id: id },function(data){
		if(data == 1) {
			$(".UnPublished:eq("+index+")").css("display", "none");
			$(".Published:eq("+index+")").css("display", "inline");
		}
		else if(data == 0) {
			$(".Published:eq("+index+")").css("display", "none");
			$(".UnPublished:eq("+index+")").css("display", "inline");
		}
		else alert("Some error occured. Make sure you are connected to the network.");
	});
}
//-->
</script>
<div id="Home">
	<div class="Notice">Select a unit to edit. Alternatively, if you would like to edit your personal information, please select the "My Account" link from the menu above.</div>
	<table id="main_menu" width="100%">
	  <tr>
	    <th width="8%">Unit ID</th>
	    <th>Address</th>
	    <th width="10%">Beds</th>
	    <th width="10%">Baths</th>
	    <th width="15%">Published?</th>
	  </tr>
	  <?php if($units){?>
	  	<?php foreach ($units as $unit){?>
		  <tr>
		    <td><a href="?option=com_resman&user=owner&page=property_details&uid=<?php echo $unit->id;?>"><?php echo $unit->id;?></a></td>
		    <td><?php echo $unit->address;?></td>
		    <td><?php echo $unit->bedrooms;?></td>
		    <td><?php echo $unit->bathrooms;?></td>
		    <td>
		    	<a class="Published" style="display: <?php echo($unit->published == 1 ? 'inline':'none')?>" href="javascript:void(0);" onclick="alter_published_state(0, '<?php echo $unit->id;?>', this)"><img alt="published" src="<?php echo ADMIN_COMPONENT_PATH.COMPONENT_PATH."images/published.png";?>" /></a>
    			<a class="UnPublished" style="display: <?php echo($unit->published != 1 ? 'inline':'none')?>" href="javascript:void(0);" onclick="alter_published_state(1, '<?php echo $unit->id;?>', this)"><img alt="not published" src="<?php echo ADMIN_COMPONENT_PATH.COMPONENT_PATH."images/cross.png";?>" /></a>
		    </td>
		  </tr>
	  	<?php }?>
	  <?php }else{?>
	  	<tr>
	  		<td colspan="5"><b>You do not have registered any home</b></td>
	  	</tr>
	  <?php }?>
	</table>
	<script type="text/javascript">
		alternate('main_menu', 'odd', 'even');
	</script>
</div>
<p style="padding-left: 5px;"><a href="?option=com_resman&user=owner&page=new">Add new unit</a></p>
<?php //$KToolBar->addLink('<a href="?option=com_resman&user=owner&page=new"><img border="0" alt="New" src="images/new_f2.png"/><br />New</a>');?>
